package com.example.springcloud.alibaba.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.example.springcloud.alibaba.service.PaymentService;
import com.example.springcloud.entities.CommonResult;
import com.example.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderNacosController {
  /*  @Resource
    private RestTemplate restTemplate;
    @Value("${service-url.nacos-user-service}")
    private String serverURL;*/
    @Resource
    private PaymentService paymentService;

    @GetMapping(value = "/consumer/payment/{id}")
    @SentinelResource(value = "getPayment")
    public CommonResult<Payment> getPayment(@PathVariable("id") Long id) {
        return paymentService.getPayment(id);
    }

/*    @GetMapping(value = "/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Long id) {
        return restTemplate.getForObject(serverURL+"/payment/nacos/"+id,String.class);
    }*/
}
